import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace BookingCheckinEventApi {
  /** 签到事件信息 */
  export interface BookingCheckinEvent {
    id: number; // 签到事件ID
    checkinMasterId?: number; // 签到主表ID
    checkinDetailId: number; // 签到明细ID
    eventType?: string; // 事件类型
    eventStatus?: string; // 事件状态
    eventTime?: string | Dayjs; // 事件时间
    eventData: string; // 事件数据
    eventResult: string; // 事件结果
    errorMessage: string; // 错误信息
    triggerType?: string; // 触发类型
    triggerUserId: number; // 触发用户ID
    triggerSource: string; // 触发来源
    processorId: number; // 处理人ID
    processTime: string | Dayjs; // 处理时间
    processNotes: string; // 处理备注
  }
}

/** 查询签到事件分页 */
export function getBookingCheckinEventPage(params: PageParam) {
  return requestClient.get<PageResult<BookingCheckinEventApi.BookingCheckinEvent>>('/spa/booking-checkin-event/page', { params });
}

/** 查询签到事件详情 */
export function getBookingCheckinEvent(id: number) {
  return requestClient.get<BookingCheckinEventApi.BookingCheckinEvent>(`/spa/booking-checkin-event/get?id=${id}`);
}

/** 新增签到事件 */
export function createBookingCheckinEvent(data: BookingCheckinEventApi.BookingCheckinEvent) {
  return requestClient.post('/spa/booking-checkin-event/create', data);
}

/** 修改签到事件 */
export function updateBookingCheckinEvent(data: BookingCheckinEventApi.BookingCheckinEvent) {
  return requestClient.put('/spa/booking-checkin-event/update', data);
}

/** 删除签到事件 */
export function deleteBookingCheckinEvent(id: number) {
  return requestClient.delete(`/spa/booking-checkin-event/delete?id=${id}`);
}


/** 导出签到事件 */
export function exportBookingCheckinEvent(params: any) {
  return requestClient.download('/spa/booking-checkin-event/export-excel', { params });
}

